package win.larryzeal.spring.test;

public class ThreadB extends Thread {

    private MyList list;

    public ThreadB(MyList list){
        this.list = list;
    }

    synchronized int size(){
        return list.size();
    }
    int tmp;

    @Override
    public void run(){
        try{
            while(true){
                // int size = list.size();
                // tmp=size;
                // System.out.println(list.size());
                // System.out.println(size);

                int size=size();
                if(size == 5){
                    System.out.println("==5线程B退出");
                    throw new InterruptedException();
                }
            }
        } catch(InterruptedException e){
            e.printStackTrace();
        }
    }

}
